import { del, down, get, post, put } from "@/common/http";
import { ITableWrap } from "@/types/common";
import { IDepartment } from "@/types/department";

/**
 *
 * @param page 页数 从1开始
 * @param pageSize 每页条数
 * @param name 用户名
 * @returns 员工分页
 */
export const departmentPage = (page: number, pageSize: number, name?: string) =>
  get<ITableWrap<IDepartment>>("/api/v1/department/page", {
    params: {
      page,
      pageSize,
      name,
    },
  });

  /**
   *
   * @param name
   * @returns 获取列表数据
   */
  export const departmentList = (name?: string) =>
  get<IDepartment[]>("/api/v1/department/list", {
    params: {
      name,
    },
  });

/**
 *
 * @param data
 * @returns 创建员工
 */
export const departmentCreate = (data: Partial<IDepartment>) =>
  post<IDepartment>("/api/v1/department", data);

/**
 *
 * @param id
 * @returns 根据id查询
 */
export const departmentGetOne = (id: string) =>
  get<IDepartment>("/api/v1/department/" + id);

/**
 *
 * @param data
 * @returns 更新
 */
export const departmentUpdate = (data: Partial<IDepartment>) =>
  put<boolean>("/api/v1/department", data);

/**
 *
 * @param params
 * @returns 删除
 */
export const departmentDel = (ids: string) =>
  del<boolean>("/api/v1/department", {
    params: { ids },
  });

/**
 *
 * @param data
 * @returns 更新
 */
export const departmentSetStatus = (status: number, ids: string) =>
  post<boolean>(
    "/api/v1/department/status/" + status,
    {},
    {
      params: {
        ids,
      },
    }
  );
